<?php
class Application_Acl_DefaultAcl extends Zend_Acl{
	public function __construct(){
		$this->_initRessources();
		$this->_initRoles();
		$this->_initRights();
		
		Zend_Registry::set('DefaultAcl', $this);
	}
	
	protected function _initRessources(){
		$this->addResource(new Zend_Acl_Resource('default:index'));
		$this->addResource(new Zend_Acl_Resource('default:news'));
		$this->addResource(new Zend_Acl_Resource('default:login'));
		$this->addResource(new Zend_Acl_Resource('default:comment'));
		$this->addResource(new Zend_Acl_Resource('default:error'));
		$this->addResource(new Zend_Acl_Resource('default:syllabus'));
		$this->addResource(new Zend_Acl_Resource('default:register'));
		$this->addResource(new Zend_Acl_Resource('default:mail'));
		$this->addResource(new Zend_Acl_Resource('admin:index'));
	}
	protected function _initRoles(){
		$guest = new Zend_Acl_Role('guest');
		$member = new Zend_Acl_Role('member');
		$admin = new Zend_Acl_Role('admin');
		
		$this->addRole($guest);
		$this->addRole($member,$guest);
		$this->addRole($admin,$member);
	}
	protected function _initRights(){
		$this->allow('guest',array(
				'default:index',
				'default:news',
				'default:error',
				'default:login',
				'default:register',
				'default:syllabus'
		));
		$this->allow('guest','default:comment',array('index'));
		$this->allow('member',array('default:comment','default:mail'));
		$this->deny('member','default:login','login');
		$this->deny('member','default:register');
		$this->allow('admin');
	}
}